package net.xuele.learn.testClass;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by GaoQingming on 2019/4/16 0016.
 */
@Slf4j
public class testClass {

    public static final String STRING = "<a id=\"thunder\" class=\"download\" href=\"thunder://QUFtYWduZXQ6P3h0PXVybjpidGloOjc1OTdDRjFBMDg0QjMyRUVERkI1QTQxNkE0MTc4RjE0MjFFMTg0OTVaWg==\" style=\"display: none;\">thunder://QUFtYWduZXQ6P3h0PXVybjpidGloOjc1OTdDRjFBMDg0QjMyRUVERkI1QTQxNkE0MTc4RjE0MjFFMTg0OTVaWg==</a>";

    public static String status = "run";
    public static Object o = new Object();
    public static void main(String[] args) {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + "退出！");
                status = "exit";
                System.out.println(status);
            }
        }, 5000);


        while ("run".equals(status)) {
            //System.out.println("当前是："+status);
            //System.out.println("123");
            //log.info("123");int
            synchronized (o) {
                int i = 1;
            }
            if ("exit".equals(status)) {
                System.out.println(Thread.currentThread().getName() + "23333");
                break;
            }
        }
        System.out.println(Thread.currentThread().getName() + "over!");
        //timer.cancel();
    }




    @Test
    public void fun() {
        int maxOrder = 11;
        int maxSubpageAllocs = 1 << maxOrder;


        // Generate the memory map.
        byte[]  memoryMap = new byte[maxSubpageAllocs << 1];
        byte[] depthMap = new byte[memoryMap.length];
        int memoryMapIndex = 1;
        for (int d = 0; d <= maxOrder; ++ d) { // move down the tree one level at a time
            int depth = 1 << d;
            System.out.println(depth);
            for (int p = 0; p < depth; ++ p) {
                // in each level traverse left to right and set value to the depth of subtree
                memoryMap[memoryMapIndex] = (byte) d;
                depthMap[memoryMapIndex] = (byte) d;
                memoryMapIndex ++;
            }

        }
        for (int i = 0; i < memoryMap.length; i++) {
            if (memoryMap[i] != depthMap[i]) {
                System.out.println("xxxxx");
            }
        }
        System.out.println(memoryMap == depthMap);
        System.out.println("over");
    }

}
